package com.zhongyewx.teachercert.db.dao;

import android.arch.lifecycle.LiveData;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.zhongyewx.teachercert.db.entity.UserEntity;

import java.util.List;

import io.reactivex.Flowable;

@Dao
public interface ZYUserDao {
    @Insert
    void insert(UserEntity userEntity);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(UserEntity... userEntities);//使用rxjava 异步插入

    @Update(onConflict = OnConflictStrategy.REPLACE)
    void updateUsers(UserEntity... userEntities);

    @Query("select * from zyteachercert_user_table order by user_name asc")
    List<UserEntity> queryAll();

    @Query("select * from zyteachercert_user_table order by user_name asc")
    Flowable<List<UserEntity>> loadUsersSync();

    @Query("delete from zyteachercert_user_table")
    void deleteAll();
}
